Feat: 添加未提取记忆补偿+遗忘曲线门控 - #69
Open
TriDefender wants to merge 12 commits into
Open
Conversation
可以重新尝试提取之前未提取的记忆节点,在正式提取前会让用户确认。
添加模仿艾宾浩斯遗忘曲线的门控机制,长期不用的节点会被deprecate掉(非硬性删除,可被重新激活)避免过时噪声影响检索结果
移植了adoresever@1fdec04 src/store/store.ts - CommunitySummary 接口新增 memberSignature: string | null - upsertCommunitySummary() 增加 memberSignature 参数,MERGE 时写入(沿用 embedding 的 CASE 保留模式:传 null 不清空旧值) - getCommunitySummary() / getAllCommunitySummaries() 返回 memberSignature - 新增 getCommunitySummaryBySignature():按签名查社区(ORDER BY updatedAt DESC LIMIT 1),带回 embedding 供复用 src/graph/community.ts - 新增导出 buildCommunityMemberSignature():成员 ID 排序后 sha1(与上游逐字等价) - summarizeCommunities() 循环内两层短路: 1. 签名未变且摘要非空 → 跳过,不调 LLM 2. 其他社区存在相同签名 + 非空摘要 → 复用其 summary + embedding,不调 LLM 3. 否则走原有 LLM 生成路径,upsert 时写入签名
This commit aims to tackle more finegrained memory control on cron sessions: Does a repeating cron session generates 'false popularity' on specific memory nodes? Now it enables you to: - disable memory extraction for cron runs - disable entirely graph functions, so it will not inject context information (it may change workflows, use this with caution since models may lack crucial information. you're advised to test the workflow before hand) - skip session end actions on cron
- 修掉了原来多会话并发结束会并发跑两次全局维护的竞态 - 防止插件启动时检测不到embeddings就整个生命周期回退到FTS
数据损坏/丢失: - gm_maintain 与后台维护链并发(validatedCount 双计、communityId 互踩): scheduleMaintenance 改为类型化单飞 promise,全部维护入口收敛同一互斥点 - computeGlobalPageRank:GDS write 成功后 drop/topK 失败不再回落 1/(i+1) 覆盖真实 PageRank(drop 失败单独吞,宁泄漏临时投影) - summarizeCommunities:prune 挪到签名复用之后——先 prune 会删掉重编号 场景下的捐赠者社区,导致每轮维护全量重算 LLM 摘要+embedding - graph-memory extract:批边界 await 所有 syncEmbed,closeDriver 不再 丢失最后一批在途向量(markExtracted 后不可自愈) - PUT /nodes:改 type 与非法边清理(EDGE_DIRECTION_RULES 生成谓词)包进 单 executeWrite 事务;name 重名预检 409、空名 400 功能失效: - db.ts:删除不可达的 driver 重连分支(驱动 5.x session() 从不抛错), getSession 永远优先模块级 _driver 单例 - llm.ts:OAuth 缓存按 oauthPath mtime 失效(CLI 刷新 token 后网关 下一次调用即生效,无需重启);Anthropic 遍历找 text 块(thinking 块 在前不再误报 empty);openai/anthropic 路径补 fetchRetry(429/5xx) - recall:双路径 Promise.all 并行 + query 向量算一次共享 + assemble 复用 未变 prompt 的缓存(4 embed/4 投影 → 1 embed/2 并行遍历) - flushMessageBuffer 成功后补排 maintenance(熔断跳过的一轮不再丢失) 竞态/一致性: - upsertNode:撞 *_name 唯一约束退回更新路径(幂等);records[0] 守卫 - upsertEdge:三段查询合并为单条 apoc.merge.relationship(消除并发重复边) - session_end finalize 包进 withExtractLock;gm_record/gm_link 溯源统一 sessionId;crud 内联 normalizeName 改用 store 导入(受一致性测试保护) 性能: - detectDuplicates:N 次向量查询折叠为单条 UNWIND+CALL - applyDecay:Math.max spread 改 reduce(防超大节点集爆栈) - assemble:2N 次串行边查询改 edgesTouching 单次批量;社区摘要并发预取 - communityRepresentatives 加 totalLimit 封顶;graphWalk clamp maxDepth - recall 超时 30s 退避(withBudget 不取消底层查询,防堆积) 配置/测试: - schema recallMaxNodes 3→6 对齐代码默认;freshTailCount 接线到 sliceLastTurn(默认 5=原硬编码 KEEP_TURNS,行为不变) - integration.recall/routes 支持 NEO4J_TEST_URI(消除 7687 硬编码) - 新增集成用例:TASK→EVENT 改 type 边清理、name 重名 409、社区摘要
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
本PR添加了两个新功能:
openclaw graph-memory这个命令行handle触发对未提取的记忆重新入库+向量化,避免某些技术原因(llm超时等)遗漏过往记忆;